Imports System.Data
Imports System.Xml
Imports System.Data.SqlClient
Imports SERPS.ARdataLogic

Public Class frmARenquiry
    Inherits System.Windows.Forms.Form
    Dim OpBal, ClBal As Decimal
    Dim opb As Decimal
    Dim util As New AppsUtility.EncDec
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents cbCustomer As DevComponents.DotNetBar.Controls.ComboBoxEx
    Friend WithEvents GroupPanel1 As DevComponents.DotNetBar.Controls.GroupPanel
    Friend WithEvents cmdRefresh As DevComponents.DotNetBar.ButtonX
    Friend WithEvents cmdExit As DevComponents.DotNetBar.ButtonX
    Public strCon As String = util.toDecrypt(System.Configuration.ConfigurationSettings.AppSettings("SQLString"))

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents Label9 As System.Windows.Forms.Label
    Friend WithEvents Label10 As System.Windows.Forms.Label
    Friend WithEvents dtpFromDate As System.Windows.Forms.DateTimePicker
    Friend WithEvents dtpToDate As System.Windows.Forms.DateTimePicker
    Friend WithEvents dgTrxEnq As System.Windows.Forms.DataGrid
    Friend WithEvents tbOpbal As System.Windows.Forms.TextBox
    Friend WithEvents tbTotalDr As System.Windows.Forms.TextBox
    Friend WithEvents tbTotalCr As System.Windows.Forms.TextBox
    Friend WithEvents tbClBal As System.Windows.Forms.TextBox
    Friend WithEvents cmbCompany As System.Windows.Forms.ComboBox
    Friend WithEvents tbCusCode As System.Windows.Forms.TextBox
    Friend WithEvents Label3 As System.Windows.Forms.Label

    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Label8 = New System.Windows.Forms.Label()
        Me.tbOpbal = New System.Windows.Forms.TextBox()
        Me.tbTotalDr = New System.Windows.Forms.TextBox()
        Me.Label9 = New System.Windows.Forms.Label()
        Me.tbTotalCr = New System.Windows.Forms.TextBox()
        Me.tbClBal = New System.Windows.Forms.TextBox()
        Me.Label10 = New System.Windows.Forms.Label()
        Me.dtpFromDate = New System.Windows.Forms.DateTimePicker()
        Me.dtpToDate = New System.Windows.Forms.DateTimePicker()
        Me.dgTrxEnq = New System.Windows.Forms.DataGrid()
        Me.cmbCompany = New System.Windows.Forms.ComboBox()
        Me.tbCusCode = New System.Windows.Forms.TextBox()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.cbCustomer = New DevComponents.DotNetBar.Controls.ComboBoxEx()
        Me.GroupPanel1 = New DevComponents.DotNetBar.Controls.GroupPanel()
        Me.cmdRefresh = New DevComponents.DotNetBar.ButtonX()
        Me.cmdExit = New DevComponents.DotNetBar.ButtonX()
        CType(Me.dgTrxEnq, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.GroupPanel1.SuspendLayout()
        Me.SuspendLayout()
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.BackColor = System.Drawing.Color.Transparent
        Me.Label2.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label2.Location = New System.Drawing.Point(443, 21)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(54, 18)
        Me.Label2.TabIndex = 53
        Me.Label2.Text = "To Date"
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.BackColor = System.Drawing.Color.Transparent
        Me.Label1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label1.Location = New System.Drawing.Point(328, 21)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(72, 18)
        Me.Label1.TabIndex = 51
        Me.Label1.Text = "From Date"
        '
        'Label8
        '
        Me.Label8.AutoSize = True
        Me.Label8.BackColor = System.Drawing.Color.Transparent
        Me.Label8.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label8.Location = New System.Drawing.Point(726, 45)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(88, 18)
        Me.Label8.TabIndex = 81
        Me.Label8.Text = "Opg .Balance"
        '
        'tbOpbal
        '
        Me.tbOpbal.BackColor = System.Drawing.Color.White
        Me.tbOpbal.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.tbOpbal.Location = New System.Drawing.Point(819, 67)
        Me.tbOpbal.Name = "tbOpbal"
        Me.tbOpbal.ReadOnly = True
        Me.tbOpbal.Size = New System.Drawing.Size(124, 26)
        Me.tbOpbal.TabIndex = 82
        Me.tbOpbal.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'tbTotalDr
        '
        Me.tbTotalDr.BackColor = System.Drawing.Color.White
        Me.tbTotalDr.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.tbTotalDr.Location = New System.Drawing.Point(689, 366)
        Me.tbTotalDr.Name = "tbTotalDr"
        Me.tbTotalDr.ReadOnly = True
        Me.tbTotalDr.Size = New System.Drawing.Size(124, 26)
        Me.tbTotalDr.TabIndex = 84
        Me.tbTotalDr.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'Label9
        '
        Me.Label9.AutoSize = True
        Me.Label9.BackColor = System.Drawing.Color.Transparent
        Me.Label9.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label9.Location = New System.Drawing.Point(640, 346)
        Me.Label9.Name = "Label9"
        Me.Label9.Size = New System.Drawing.Size(38, 18)
        Me.Label9.TabIndex = 83
        Me.Label9.Text = "Total"
        '
        'tbTotalCr
        '
        Me.tbTotalCr.BackColor = System.Drawing.Color.White
        Me.tbTotalCr.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.tbTotalCr.Location = New System.Drawing.Point(819, 366)
        Me.tbTotalCr.Name = "tbTotalCr"
        Me.tbTotalCr.ReadOnly = True
        Me.tbTotalCr.Size = New System.Drawing.Size(124, 26)
        Me.tbTotalCr.TabIndex = 85
        Me.tbTotalCr.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'tbClBal
        '
        Me.tbClBal.BackColor = System.Drawing.Color.White
        Me.tbClBal.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.tbClBal.Location = New System.Drawing.Point(819, 397)
        Me.tbClBal.Name = "tbClBal"
        Me.tbClBal.ReadOnly = True
        Me.tbClBal.Size = New System.Drawing.Size(124, 26)
        Me.tbClBal.TabIndex = 87
        Me.tbClBal.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'Label10
        '
        Me.Label10.AutoSize = True
        Me.Label10.BackColor = System.Drawing.Color.Transparent
        Me.Label10.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label10.Location = New System.Drawing.Point(726, 377)
        Me.Label10.Name = "Label10"
        Me.Label10.Size = New System.Drawing.Size(82, 18)
        Me.Label10.TabIndex = 86
        Me.Label10.Text = "Clg. Balance"
        '
        'dtpFromDate
        '
        Me.dtpFromDate.Format = System.Windows.Forms.DateTimePickerFormat.[Short]
        Me.dtpFromDate.Location = New System.Drawing.Point(333, 65)
        Me.dtpFromDate.Name = "dtpFromDate"
        Me.dtpFromDate.Size = New System.Drawing.Size(109, 26)
        Me.dtpFromDate.TabIndex = 153
        '
        'dtpToDate
        '
        Me.dtpToDate.Format = System.Windows.Forms.DateTimePickerFormat.[Short]
        Me.dtpToDate.Location = New System.Drawing.Point(448, 65)
        Me.dtpToDate.Name = "dtpToDate"
        Me.dtpToDate.Size = New System.Drawing.Size(109, 26)
        Me.dtpToDate.TabIndex = 154
        '
        'dgTrxEnq
        '
        Me.dgTrxEnq.BackColor = System.Drawing.Color.AliceBlue
        Me.dgTrxEnq.BackgroundColor = System.Drawing.Color.AliceBlue
        Me.dgTrxEnq.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.dgTrxEnq.CaptionVisible = False
        Me.dgTrxEnq.DataMember = ""
        Me.dgTrxEnq.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgTrxEnq.Location = New System.Drawing.Point(16, 100)
        Me.dgTrxEnq.Name = "dgTrxEnq"
        Me.dgTrxEnq.PreferredColumnWidth = 175
        Me.dgTrxEnq.ReadOnly = True
        Me.dgTrxEnq.Size = New System.Drawing.Size(927, 260)
        Me.dgTrxEnq.TabIndex = 155
        Me.dgTrxEnq.TabStop = False
        '
        'cmbCompany
        '
        Me.cmbCompany.BackColor = System.Drawing.Color.AliceBlue
        Me.cmbCompany.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cmbCompany.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmbCompany.ItemHeight = 14
        Me.cmbCompany.Location = New System.Drawing.Point(87, 397)
        Me.cmbCompany.Name = "cmbCompany"
        Me.cmbCompany.Size = New System.Drawing.Size(208, 22)
        Me.cmbCompany.TabIndex = 88
        Me.cmbCompany.Visible = False
        '
        'tbCusCode
        '
        Me.tbCusCode.BackColor = System.Drawing.Color.White
        Me.tbCusCode.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.tbCusCode.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.tbCusCode.Location = New System.Drawing.Point(232, 36)
        Me.tbCusCode.MaxLength = 6
        Me.tbCusCode.Name = "tbCusCode"
        Me.tbCusCode.Size = New System.Drawing.Size(92, 26)
        Me.tbCusCode.TabIndex = 156
        '
        'Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.BackColor = System.Drawing.Color.Transparent
        Me.Label3.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label3.Location = New System.Drawing.Point(11, 21)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(100, 18)
        Me.Label3.TabIndex = 157
        Me.Label3.Text = "Customer Info."
        '
        'Label4
        '
        Me.Label4.AutoSize = True
        Me.Label4.BackColor = System.Drawing.Color.Transparent
        Me.Label4.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label4.Location = New System.Drawing.Point(83, 353)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(66, 18)
        Me.Label4.TabIndex = 53
        Me.Label4.Text = "Company"
        Me.Label4.Visible = False
        '
        'cbCustomer
        '
        Me.cbCustomer.DisplayMember = "Text"
        Me.cbCustomer.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed
        Me.cbCustomer.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cbCustomer.ItemHeight = 19
        Me.cbCustomer.Location = New System.Drawing.Point(18, 65)
        Me.cbCustomer.Name = "cbCustomer"
        Me.cbCustomer.Size = New System.Drawing.Size(308, 25)
        Me.cbCustomer.TabIndex = 158
        '
        'GroupPanel1
        '
        Me.GroupPanel1.CanvasColor = System.Drawing.SystemColors.Control
        Me.GroupPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007
        Me.GroupPanel1.Controls.Add(Me.cmdRefresh)
        Me.GroupPanel1.Controls.Add(Me.cmdExit)
        Me.GroupPanel1.Controls.Add(Me.Label8)
        Me.GroupPanel1.Controls.Add(Me.Label1)
        Me.GroupPanel1.Controls.Add(Me.Label3)
        Me.GroupPanel1.Controls.Add(Me.Label2)
        Me.GroupPanel1.Controls.Add(Me.Label4)
        Me.GroupPanel1.Controls.Add(Me.Label9)
        Me.GroupPanel1.Controls.Add(Me.Label10)
        Me.GroupPanel1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.GroupPanel1.Location = New System.Drawing.Point(0, 0)
        Me.GroupPanel1.Name = "GroupPanel1"
        Me.GroupPanel1.Size = New System.Drawing.Size(960, 493)
        '
        '
        '
        Me.GroupPanel1.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2
        Me.GroupPanel1.Style.BackColorGradientAngle = 90
        Me.GroupPanel1.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground
        Me.GroupPanel1.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderBottomWidth = 1
        Me.GroupPanel1.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder
        Me.GroupPanel1.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderLeftWidth = 1
        Me.GroupPanel1.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderRightWidth = 1
        Me.GroupPanel1.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderTopWidth = 1
        Me.GroupPanel1.Style.CornerDiameter = 4
        Me.GroupPanel1.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded
        Me.GroupPanel1.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center
        Me.GroupPanel1.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText
        Me.GroupPanel1.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near
        Me.GroupPanel1.TabIndex = 159
        Me.GroupPanel1.Text = "AR Enquiry"
        '
        'cmdRefresh
        '
        Me.cmdRefresh.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdRefresh.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdRefresh.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdRefresh.Location = New System.Drawing.Point(770, 430)
        Me.cmdRefresh.Name = "cmdRefresh"
        Me.cmdRefresh.Size = New System.Drawing.Size(82, 27)
        Me.cmdRefresh.TabIndex = 254
        Me.cmdRefresh.Text = "Refresh"
        '
        'cmdExit
        '
        Me.cmdExit.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdExit.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdExit.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdExit.Location = New System.Drawing.Point(858, 430)
        Me.cmdExit.Name = "cmdExit"
        Me.cmdExit.Size = New System.Drawing.Size(82, 27)
        Me.cmdExit.TabIndex = 253
        Me.cmdExit.Text = "Exit"
        '
        'ARenquiry
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(7, 19)
        Me.BackColor = System.Drawing.SystemColors.ActiveCaption
        Me.ClientSize = New System.Drawing.Size(960, 493)
        Me.ControlBox = False
        Me.Controls.Add(Me.cbCustomer)
        Me.Controls.Add(Me.tbOpbal)
        Me.Controls.Add(Me.tbCusCode)
        Me.Controls.Add(Me.dgTrxEnq)
        Me.Controls.Add(Me.dtpToDate)
        Me.Controls.Add(Me.dtpFromDate)
        Me.Controls.Add(Me.cmbCompany)
        Me.Controls.Add(Me.tbClBal)
        Me.Controls.Add(Me.tbTotalCr)
        Me.Controls.Add(Me.tbTotalDr)
        Me.Controls.Add(Me.GroupPanel1)
        Me.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.ForeColor = System.Drawing.SystemColors.ControlLightLight
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.Location = New System.Drawing.Point(50, 70)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "ARenquiry"
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        CType(Me.dgTrxEnq, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupPanel1.ResumeLayout(False)
        Me.GroupPanel1.PerformLayout()
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

#End Region
    Private Sub Budgets_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ICdata As New ICdataLogic
        Dim ds, ds2 As DataSet
        ds = ICdata.GetAllCompany()
        cmbCompany.DataSource = ds.Tables(0)
        cmbCompany.ValueMember = "CompanyID"
        cmbCompany.DisplayMember = "CompanyName"
        cmbCompany.SelectedValue = CompanyID
        ds2 = ICdata.GetCompanyCustomers(CompanyID)
        cbCustomer.DataSource = ds2.Tables(0)
        cbCustomer.ValueMember = "CusID"
        cbCustomer.DisplayMember = "CusName"
        'Customer_load()
        'dgTrxEnq_load()
    End Sub
    Private Sub dgTrxEnq_load()
        Try
            Dim FrDt, ToDt As String
            FrDt = dtpFromDate.Text
            ToDt = dtpToDate.Text
            FrDt = FrDt.Substring(6, 4) & "-" & FrDt.Substring(3, 2) & "-" & FrDt.Substring(0, 2)
            ToDt = ToDt.Substring(6, 4) & "-" & ToDt.Substring(3, 2) & "-" & ToDt.Substring(0, 2)
            Dim strsql As String
            Dim sqlCon As SqlConnection = New SqlConnection(strCon)
            sqlCon.Open()
            strsql = "select DocNum,DocDate,DocType,DocAmt DrAmount,null CrAmount,DocRefer,TrxNumber,DocsMan from ARTRX where CusID=" & cbCustomer.SelectedValue & " and " & _
            "(DocDate between '" & FrDt & "' and '" & ToDt & "') " & _
            "and DocAmt>0 " & _
            "UNION ALL " & _
            "select DocNum,DocDate,DocType,null DrAmount,abs(DocAmt) CrAmount,DocRefer,TrxNumber,DocsMan from ARTRX where CusID=" & cbCustomer.SelectedValue & " and " & _
            "(DocDate between '" & FrDt & "' and '" & ToDt & "') " & _
            "and DocAmt<0 " & _
            " order by DocDate "


            Dim da As New SqlClient.SqlDataAdapter(strsql, sqlCon)
            Dim ds As New DataSet("TRENQ")
            da.Fill(ds, "TRENQ")
            Dim drow As DataRow
            Dim DrTot, CrTot As Decimal

            ds.Tables("TRENQ").Columns.Add("Balance")
            ds.Tables("TRENQ").Columns.Add("Sales Man")

            Dim balint As Decimal

            balint = opb

            Dim ARdata As New ARdataLogic
            Dim dsw As New DataSet("C")
            'Dim dsw As String
            For Each drow In ds.Tables(0).Rows
                If Not IsDBNull(drow("DrAmount")) Then
                    DrTot += Decimal.Parse(drow("DrAmount"))
                    balint = balint + Decimal.Parse(drow("DrAmount"))
                    drow("Balance") = balint
                End If
                If Not IsDBNull(drow("CrAmount")) Then
                    CrTot += Decimal.Parse(drow("CrAmount"))
                    balint = balint - Decimal.Parse(drow("CrAmount"))
                    drow("Balance") = balint
                End If


                'If IsDBNull(drow("Balance")) Then
                '    drow("Sales Man") = "N/A"
                'Else
                '    dsw = ARdata.RetrieveUserName(drow("DocsMan"))
                '    If dsw.Tables("C").Rows.Count > 1 Then
                '        drow("Sales Man") = "N/A"
                '    Else
                '        drow("Sales Man") = dsw.Tables("C").Rows(0)(0)
                '    End If
                'End If


            Next
            tbTotalDr.Text = DrTot.ToString("#0.000")
            tbTotalCr.Text = CrTot.ToString("#0.000")

            dgTrxEnq.DataSource = ds
            dgTrxEnq.DataMember = "TRENQ"
            dgTrxEnq.ReadOnly = True
            dgTrxEnq.TableStyles.Clear()
            dgTrxEnq_Style()
            sqlCon.Close()
        Catch ex As Exception
            MsgBox("body : " & ex.ToString)
        End Try
    End Sub

    Private Sub dgTrxEnq_Style()
        With dgTrxEnq
            .TableStyles.Clear()
            .CaptionBackColor = System.Drawing.Color.SlateBlue
            .CaptionForeColor = System.Drawing.Color.LemonChiffon
            .AllowSorting = True
            .AlternatingBackColor = System.Drawing.Color.AliceBlue
            .ParentRowsBackColor = System.Drawing.Color.Lavender
            .ParentRowsForeColor = System.Drawing.Color.SlateBlue
            .HeaderBackColor = System.Drawing.Color.LemonChiffon
            .AllowNavigation = False
            .ParentRowsVisible = False
            .RowHeadersVisible = False
        End With

        Dim grdTableStyle As New DataGridTableStyle
        With grdTableStyle
            .AlternatingBackColor = Color.AliceBlue
            .HeaderFont = New Font("Tahoma", 8.0!, FontStyle.Bold)
            .MappingName = "TRENQ"
            .PreferredColumnWidth = 160
            .HeaderBackColor = Color.LightSlateGray
            .HeaderForeColor = Color.LightCyan
            .PreferredRowHeight = 15
            .RowHeadersVisible = False
            .RowHeaderWidth = 0
        End With



        Dim cs As DataGridColumnStyle
        cs = New DataGridTextBoxColumn
        cs.Width = 90
        cs.MappingName = "DocDate"
        cs.HeaderText = "Date"
        cs.NullText = ""
        grdTableStyle.GridColumnStyles.Add(cs)

        Dim cs1 As DataGridColumnStyle
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 80
        cs1.MappingName = "DocNum"
        cs1.HeaderText = "Doc.No."
        cs1.NullText = ""
        grdTableStyle.GridColumnStyles.Add(cs1)

        Dim cs5 As DataGridColumnStyle
        cs5 = New DataGridTextBoxColumn
        cs5.Width = 65
        cs5.MappingName = "DocType"
        cs5.HeaderText = "Type"
        cs5.NullText = ""
        grdTableStyle.GridColumnStyles.Add(cs5)


        Dim cs2 As DataGridColumnStyle
        cs2 = New DataGridTextBoxColumn  ' Add the standard column style.
        cs2.Width = 220
        cs2.MappingName = "DocRefer"
        cs2.HeaderText = "Description"
        cs2.NullText = ""
        cs2.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs2)

        Dim cs3 As DataGridColumnStyle
        cs3 = New DataGridTextBoxColumn
        cs3.Width = 100
        cs3.MappingName = "TrxNumber"
        cs3.HeaderText = "Trx.No."
        cs3.NullText = ""
        grdTableStyle.GridColumnStyles.Add(cs3)

        Dim cs0 As DataGridColumnStyle
        cs0 = New DataGridTextBoxColumn  ' Add the standard column style.
        cs0.Width = 115
        cs0.MappingName = "DrAmount"
        cs0.HeaderText = "Debit Amount "
        cs0.NullText = ""
        cs0.ReadOnly = True
        cs0.Alignment = HorizontalAlignment.Right
        grdTableStyle.GridColumnStyles.Add(cs0)

        Dim cs4 As DataGridColumnStyle
        cs4 = New DataGridTextBoxColumn  ' Add the standard column style.
        cs4.Width = 115
        cs4.MappingName = "CrAmount"
        cs4.HeaderText = "Credit Amount "
        cs4.NullText = ""
        cs4.ReadOnly = True
        cs4.Alignment = HorizontalAlignment.Right
        grdTableStyle.GridColumnStyles.Add(cs4)

        cs4 = New DataGridTextBoxColumn  ' Add the standard column style.
        cs4.Width = 115
        cs4.MappingName = "Balance"
        cs4.HeaderText = "Balance"
        cs4.NullText = ""
        cs4.ReadOnly = True
        cs4.Alignment = HorizontalAlignment.Right
        grdTableStyle.GridColumnStyles.Add(cs4)

        'cs4 = New DataGridTextBoxColumn  ' Add the standard column style.
        'cs4.Width = 105
        'cs4.MappingName = "Sales Man"
        'cs4.HeaderText = "Sales Man"
        'cs4.NullText = ""
        'cs4.ReadOnly = True
        'cs4.Alignment = HorizontalAlignment.Right
        'grdTableStyle.GridColumnStyles.Add(cs4)

        dgTrxEnq.TableStyles.Add(grdTableStyle)

    End Sub

    Private Function GetBBFQty()
        Try
            Dim FrDt, ToDt As String
            FrDt = dtpFromDate.Text
            ToDt = dtpToDate.Text
            FrDt = FrDt.Substring(6, 4) & "-" & FrDt.Substring(3, 2) & "-" & FrDt.Substring(0, 2)
            ToDt = ToDt.Substring(6, 4) & "-" & ToDt.Substring(3, 2) & "-" & ToDt.Substring(0, 2)

            Dim strsql As String
            Dim sqlCon As SqlConnection = New SqlConnection(strCon)
            sqlCon.Open()
            Dim sqlCMD As New SqlCommand(strsql, sqlCon)
            strsql = "Select isnull(Sum(DocAmt),0) Q from ARTrx " & _
                     " Where CusID=" & cbCustomer.SelectedValue & " " & _
                     " and (DocDate < '" & FrDt & "') "
            sqlCMD.CommandText = strsql
            If sqlCon.State = ConnectionState.Closed Then
                sqlCon.Open()
            End If
            Dim rdr As SqlDataReader
            rdr = sqlCMD.ExecuteReader
            Dim BFQty As Double = 0
            If rdr.HasRows Then
                While rdr.Read
                    BFQty = rdr("Q")
                End While
            End If
            rdr.Close()
            sqlCon.Close()
            OpBal = BFQty
            Dim amt As String = BFQty.ToString()
            If BFQty < 0 Then
                tbOpbal.Text = amt.Replace("-", "") + " Cr"
                opb = amt
            Else
                tbOpbal.Text = amt.Replace("-", "") + " Dr"
                opb = amt
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Function

    Private Function GetClosingQty()
        Try
            Dim FrDt, ToDt As String
            FrDt = dtpFromDate.Text
            ToDt = dtpToDate.Text
            FrDt = FrDt.Substring(6, 4) & "-" & FrDt.Substring(3, 2) & "-" & FrDt.Substring(0, 2)
            ToDt = ToDt.Substring(6, 4) & "-" & ToDt.Substring(3, 2) & "-" & ToDt.Substring(0, 2)

            Dim strsql As String
            Dim sqlCon As SqlConnection = New SqlConnection(strCon)
            sqlCon.Open()
            Dim sqlCMD As New SqlCommand(strsql, sqlCon)

            strsql = "Select isnull(Sum(DocAmt),0) Q from ARTrx " & _
                     " Where CusID=" & cbCustomer.SelectedValue & " " & _
                     " and (DocDate <= '" & ToDt & "') "
            sqlCMD.CommandText = strsql
            If sqlCon.State = ConnectionState.Closed Then
                sqlCon.Open()
            End If
            Dim rdr As SqlDataReader
            rdr = sqlCMD.ExecuteReader
            Dim BFQty As Double = 0
            If rdr.HasRows Then
                While rdr.Read
                    BFQty = rdr("Q")
                End While
            End If
            rdr.Close()
            sqlCon.Close()
            ClBal = BFQty
            Dim amt As String = BFQty.ToString()
            If BFQty < 0 Then
                tbClBal.Text = amt.Replace("-", "") + " Cr"
            Else
                tbClBal.Text = amt.Replace("-", "") + " Dr"
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Function

    'Private Sub Customer_load()
    '    Try
    '        'strsql = "SELECT CustNum,CustName FROM CustomerMaster ORDER BY CustName"
    '        strsql = "Exec ALLCUSTOMER "
    '        If sqlCon.State = ConnectionState.Closed Then
    '            sqlCon.Open()
    '        End If
    '        sqlCmd.CommandText = strsql
    '        Dim da As New SqlClient.SqlDataAdapter(strsql, sqlCon)
    '        Dim ds As New DataSet("SMAN")
    '        da.Fill(ds, "SMAN")
    '        cbCustomer.DataSource = ds.Tables(0)
    '        cbCustomer.DisplayMember = "CustName"
    '        cbCustomer.ValueMember = "CustNum"
    '        cbCustomer.SelectedValue = ""
    '        sqlCon.Close()
    '    Catch ex As Exception
    '        MsgBox(ex.ToString)
    '        Beep()
    '    End Try
    'End Sub
    Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
        Me.Hide()
    End Sub

    Private Sub cmdRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRefresh.Click
        GetBBFQty()
        GetClosingQty()
        dgTrxEnq_load()
    End Sub



    'Private Function gridTotal()
    '    Dim rowCount As Integer = dgTrxEnq.BindingContext(dgTrxEnq.DataSource, dgTrxEnq.DataMember).Count
    '    Dim row As Integer = dgTrxEnq.CurrentRowIndex
    '    Dim grosstotal As Double
    '    For row = 0 To rowCount - 1
    '        grosstotal += dgTrxEnq(row, 5)
    '    Next
    '    Return grosstotal
    'End Function

    Private Sub PrintGLTrx(ByVal Pcode As String)
        'Dim ds As DataSet = New DataSet("GLEnqRpt")
        'Dim table As DataTable = New DataTable("GLEnqRpt")
        'table.Columns.Add("TrxDate")
        'table.Columns.Add("TrxSource")
        'table.Columns.Add("DrAmount")
        'table.Columns.Add("CrAmount")
        'table.Columns.Add("TrxRefer")
        'table.Columns.Add("TrxNumber")

        'Dim rowCount As Integer = dgTrxEnq.BindingContext(dgTrxEnq.DataSource, dgTrxEnq.DataMember).Count
        'Dim row As Integer = dgTrxEnq.CurrentRowIndex

        'For row = 0 To rowCount - 1
        '    Dim nrow As DataRow = table.NewRow()
        '    nrow("TrxDate") = dgTrxEnq(row, 0)
        '    nrow("TrxSource") = dgTrxEnq(row, 1)
        '    nrow("DrAmount") = dgTrxEnq(row, 2)
        '    nrow("CrAmount") = dgTrxEnq(row, 3)
        '    nrow("TrxRefer") = dgTrxEnq(row, 4)
        '    nrow("TrxNumber") = dgTrxEnq(row, 5)
        '    table.Rows.Add(nrow)
        'Next

        'Dim FrDt As String = FrDate.Text
        'Dim ToDt As String = ToDate.Text
        'Dim pdesc As String = AccountName.Text

        'ds.Tables.Add(table)

        'iprint.Load(GLEnqPrintPath)
        'iprint.SetDataSource(ds)
        'iprint.SetParameterValue("AccountCode", Pcode)
        'iprint.SetParameterValue("FromDate", FrDt)
        'iprint.SetParameterValue("ToDate", ToDt)
        'iprint.SetParameterValue("AccountName", pdesc)
        'iprint.SetParameterValue("BBFQTY", opbSign.Text)
        'iprint.SetParameterValue("CLOQTY", clbSign.Text)



        ''  Dim AmountWords As String = AmountToWords(Net)
        '' iprint.SetParameterValue("AmountWords", AmountWords)
        ''iprint.SetParameterValue("BOTTOMMESSAGE", btmmsg & vbNewLine & WarSerials)
        '' iprint.PrintOptions.PrinterName = "Epson LQ-300 ESC/P 2"
        ''print.PrintOptions.PrinterName = InvoicePrinter
        'iprint.PrintToPrinter(1, True, 0, 0)
        ''CrystalReportViewer1.ReportSource = iprint
        ''CrystalReportViewer1.Visible = True
    End Sub

    Private Sub btPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Try
            'PrintGLTrx(MainCode.Text)
            cmdRefresh.PerformClick()
            Dim row As Integer = dgTrxEnq.CurrentRowIndex
            If row >= 0 Then
                PrintSupplier() ' PrintGLTrx(MainCode.Text)
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try


    End Sub


    'Private Sub cbCustomer_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles cbCustomer.Validating
    '    Try
    '        strsql = "SELECT CustNum FROM CustomerMaster where CustName='" & _
    '       Q(cbCustomer.Text) & "'"
    '        If sqlCon.State = ConnectionState.Closed Then
    '            sqlCon.Open()
    '        End If
    '        sqlCmd.CommandText = strsql
    '        rdr = sqlCmd.ExecuteReader
    '        Dim scode As String
    '        If rdr.HasRows Then
    '            While rdr.Read
    '                scode = rdr("CustNum")
    '            End While
    '        Else
    '            scode = ""
    '        End If
    '        rdr.Close()
    '        sqlCon.Close()
    '        MainCode.Text = scode
    '    Catch ex As Exception
    '        MsgBox(ex.ToString)
    '    End Try
    'End Sub
    Private Sub cbCustomer_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
        AutoCompleteCombo_KeyUp(cbCustomer, e)
        If e.KeyCode = Keys.Enter Then
            SendKeys.Send("{Tab}")
        End If
    End Sub
    Private Sub cbCustomer_Leave(ByVal sender As Object, ByVal e As System.EventArgs)
        AutoCompleteCombo_Leave(cbCustomer)
    End Sub

    Private Sub PrintSupplier()
        'Try
        '    Dim BBFDate As Date = (Convert.ToDateTime(dtpFromDate.Text)).AddDays(-1)
        '    Dim BBYType As String = "B"
        '    Dim BBFRef As String = "BALANCE B/F"
        '    Dim BBFDrAmt, BBFCrAmt As Double
        '    Dim opAmt As String
        '    Dim ln1 As Integer
        '    opAmt = tbOpbal.Text
        '    ln1 = opAmt.Length
        '    If opAmt <> "" Then
        '        If opAmt.Substring(ln1 - 2, 2) = "Dr" Then
        '            BBFDrAmt = Convert.ToDouble(opAmt.Remove(ln1 - 2, 2))
        '            BBFCrAmt = 0
        '        Else
        '            BBFCrAmt = Convert.ToDouble(opAmt.Remove(ln1 - 2, 2))
        '            BBFDrAmt = 0
        '        End If
        '    End If
        '    Dim Customer As String = "(" & CStr(cbCustomer.SelectedValue) & ") : " & cbCustomer.Text
        '    Dim ds As DataSet = New DataSet("GlTrxEnqRpt")
        '    Dim table As DataTable = New DataTable("GlTrxEnqRpt")
        '    table.Columns.Add("TrxDate")
        '    table.Columns.Add("Type")
        '    table.Columns.Add("TrxSource")
        '    table.Columns.Add("TrxNumber")
        '    table.Columns.Add("DrAmount")
        '    table.Columns.Add("CrAmount")
        '    table.Columns.Add("TrxRefer")


        '    Dim rowCount As Integer = dgTrxEnq.BindingContext(dgTrxEnq.DataSource, dgTrxEnq.DataMember).Count
        '    Dim row As Integer = dgTrxEnq.CurrentRowIndex
        '    For row = 0 To rowCount - 1
        '        Dim nrow As DataRow = table.NewRow()
        '        nrow("TrxDate") = dgTrxEnq(row, 0)
        '        nrow("TrxSource") = dgTrxEnq(row, 1)
        '        nrow("Type") = dgTrxEnq(row, 2)
        '        nrow("DrAmount") = dgTrxEnq(row, 3)
        '        nrow("CrAmount") = dgTrxEnq(row, 4)
        '        nrow("TrxRefer") = dgTrxEnq(row, 5)
        '        nrow("TrxNumber") = dgTrxEnq(row, 6)
        '        table.Rows.Add(nrow)
        '    Next
        '    Dim PP1, PP2, PP3 As String

        '    ds.Tables.Add(table)
        '    iprint.Load(ArTrxEnqPrintPath)
        '    iprint.SetDataSource(ds)
        '    iprint.SetParameterValue("Customername", Customer)
        '    iprint.SetParameterValue("FrDate", FrDate.Text)
        '    iprint.SetParameterValue("ToDate", ToDate.Text)
        '    iprint.SetParameterValue("BBFDate", BBFDate)
        '    iprint.SetParameterValue("BBFDrAmt", Convert.ToDouble(BBFDrAmt))
        '    iprint.SetParameterValue("BBFCrAmt", Convert.ToDouble(BBFCrAmt))
        '    ' iprint.SetParameterValue("BBFCrFc", Convert.ToDouble(BBFCrFcAmt))
        '    '  iprint.SetParameterValue("BBFDrFc", Convert.ToDouble(BBFDrFcAmt))


        '    If PrntPrv Is Nothing Then
        '        PrntPrv = New PrintPreview
        '        PrntPrv.CrRptView.ReportSource = iprint
        '        PrntPrv.ShowDialog()
        '    End If
        '    'iPrint.PrintToPrinter(1, True, 0, 0)
        'Catch ex As Exception
        '    MsgBox(ex.ToString)
        'End Try
    End Sub

    'Private Sub dgPend_load()
    '    Try

    '        FrDt = FrDate.Text
    '        ToDt = ToDate.Text
    '        'strsql = "select DocNum,DocDate,DocType,DocAmt DrAmount,DocRefer," & _
    '        '"TrxNumber,DocPaidAmt,datediff(day,DocDate,getdate()) span from ARTRX where DocCus='" & _
    '        'Q(MainCode.Text) & "' and " & _
    '        '"(DocDate between '" & FrDt & "' and '" & ToDt & "') " & _
    '        '"and DocAmt+DocPaidAmt<>0 and DocType='s' " & _
    '        '" order by DocDate "
    '        strsql = "select DocNum,DocDate,DocType,DocAmt DrAmount,DocRefer," & _
    '        "TrxNumber,DocPaidAmt,datediff(day,DocDate,getdate()) span from ARTRX where DocCus='" & _
    '        Q(MainCode.Text) & "' " & _
    '        "and DocAmt+DocPaidAmt<>0 and DocType='s' " & _
    '        " order by DocDate "
    '        Dim da As New SqlClient.SqlDataAdapter(strsql, sqlCon)
    '        Dim ds As New DataSet("PEND")
    '        da.Fill(ds, "PEND")

    '        dgPend.DataSource = ds
    '        dgPend.DataMember = "PEND"
    '        dgPend.ReadOnly = True
    '        dgPend.TableStyles.Clear()
    '        dgPend_Style()

    '    Catch ex As Exception
    '        MsgBox(ex.ToString)
    '    End Try
    'End Sub

    'Private Sub dgPend_Style()
    '    With dgPend
    '        '.BackColor = Color.GhostWhite
    '        .BackgroundColor = Color.LightBlue 'DarkSlateBlue 'Lavender
    '        .BorderStyle = BorderStyle.None
    '        .CaptionBackColor = Color.RoyalBlue
    '        .CaptionFont = New Font("Tahoma", 10.0!, FontStyle.Bold)
    '        .CaptionForeColor = Color.Bisque 'DarkRed '
    '        .CaptionText = "Product Details"
    '        .Font = New Font("Tahoma", 8.0!)
    '        .ParentRowsBackColor = Color.Lavender
    '        .ParentRowsForeColor = Color.MidnightBlue
    '        .ReadOnly = True
    '    End With

    '    Dim grdTableStyle As New DataGridTableStyle
    '    With grdTableStyle
    '        .AlternatingBackColor = Color.LightSteelBlue 'GhostWhite
    '        .BackColor = Color.PowderBlue 'GhostWhite
    '        .ForeColor = Color.MidnightBlue
    '        .GridLineColor = Color.LightSlateGray 'RoyalBlue
    '        .HeaderBackColor = Color.CadetBlue 'MidnightBlue
    '        .HeaderFont = New Font("Tahoma", 8.0!, FontStyle.Bold)
    '        .HeaderForeColor = Color.Lavender
    '        .SelectionBackColor = Color.Teal
    '        .SelectionForeColor = Color.PaleGreen
    '        .MappingName = "PEND"
    '        .PreferredColumnWidth = 160
    '        .PreferredRowHeight = 15
    '    End With


    '    Dim cs As DataGridColumnStyle
    '    cs = New DataGridTextBoxColumn
    '    cs.Width = 80
    '    cs.MappingName = "DocDate"
    '    cs.HeaderText = "Date"
    '    cs.NullText = ""
    '    grdTableStyle.GridColumnStyles.Add(cs)

    '    Dim cs1 As DataGridColumnStyle
    '    cs1 = New DataGridTextBoxColumn
    '    cs1.Width = 70
    '    cs1.MappingName = "DocNum"
    '    cs1.HeaderText = "Doc.No."
    '    cs1.NullText = ""
    '    grdTableStyle.GridColumnStyles.Add(cs1)

    '    Dim cs5 As DataGridColumnStyle
    '    cs5 = New DataGridTextBoxColumn
    '    cs5.Width = 50
    '    cs5.MappingName = "DocType"
    '    cs5.HeaderText = "Type"
    '    cs5.NullText = ""
    '    grdTableStyle.GridColumnStyles.Add(cs5)

    '    Dim cs0 As DataGridColumnStyle
    '    cs0 = New DataGridTextBoxColumn  ' Add the standard column style.
    '    cs0.Width = 80
    '    cs0.MappingName = "DrAmount"
    '    cs0.HeaderText = "Dr. Amount "
    '    cs0.NullText = ""
    '    cs0.ReadOnly = True
    '    cs0.Alignment = HorizontalAlignment.Right
    '    grdTableStyle.GridColumnStyles.Add(cs0)


    '    Dim cs4 As DataGridColumnStyle
    '    cs4 = New DataGridTextBoxColumn  ' Add the standard column style.
    '    cs4.Width = 60
    '    cs4.MappingName = "DocPaidAmt"
    '    cs4.HeaderText = "Paid "
    '    cs4.NullText = ""
    '    cs4.ReadOnly = True
    '    cs4.Alignment = HorizontalAlignment.Right
    '    grdTableStyle.GridColumnStyles.Add(cs4)

    '    Dim cs2 As DataGridColumnStyle
    '    cs2 = New DataGridTextBoxColumn  ' Add the standard column style.
    '    cs2.Width = 140
    '    cs2.MappingName = "DocRefer"
    '    cs2.HeaderText = "Description"
    '    cs2.NullText = ""
    '    cs2.ReadOnly = True
    '    grdTableStyle.GridColumnStyles.Add(cs2)

    '    Dim cs3 As DataGridColumnStyle
    '    cs3 = New DataGridTextBoxColumn
    '    cs3.Width = 80
    '    cs3.MappingName = "TrxNumber"
    '    cs3.HeaderText = "Trx.No."
    '    cs3.NullText = ""
    '    grdTableStyle.GridColumnStyles.Add(cs3)


    '    Dim cs6 As DataGridColumnStyle
    '    cs6 = New DataGridTextBoxColumn
    '    cs6.Width = 70
    '    cs6.MappingName = "Span"
    '    cs6.HeaderText = "Span(Days)"
    '    cs6.NullText = ""
    '    cs6.Alignment = HorizontalAlignment.Center
    '    grdTableStyle.GridColumnStyles.Add(cs6)

    '    dgPend.TableStyles.Add(grdTableStyle)
    'End Sub

    'Private Sub btPend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btPend.Click
    '    Try
    '        PaPend.Visible = True
    '        dgPend_load()
    '    Catch ex As Exception
    '        MsgBox(ex.ToString)
    '    End Try
    'End Sub

    'Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    '    PaPend.Visible = False
    'End Sub

    Private Sub tbCusCode_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles tbCusCode.LostFocus
        If tbCusCode.Text.Trim <> "" Then
            Dim ARdata As New ARdataLogic
            Dim CusID As Integer
            CusID = ARdata.GetCustomerID(tbCusCode.Text)
            If CusID = 0 Then
                MsgBox("Invalid Customer Code!", MsgBoxStyle.Critical, "Inventory Manager")
                tbCusCode.Clear()
            Else
                cbCustomer.SelectedValue = CusID
            End If
        End If
    End Sub

    Private Sub cbCustomer_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If IsNumeric(cbCustomer.SelectedValue) Then
            Dim ARdata As New ARdataLogic
            Dim CusCode As String
            CusCode = ARdata.GetCustomerCode(cbCustomer.SelectedValue)
            If CusCode.Trim = "" Then
                MsgBox("Invalid Customer!", MsgBoxStyle.Critical, "Inventory Manager")
            Else
                tbCusCode.Text = CusCode
            End If
        End If
    End Sub
End Class
